<template>
	<view class="index">
		<view class="search">
			<text class="icon-search" style=""></text>
			<input type="text" placeholder="请输入门店名称" v-model="inputVal" @input="searchData" />
		</view>
		<view class="list" v-for="(item, index) in dataList" :key="index">
			<view class="title">{{ item.ShopName }}</view>
			<view class="phone">{{ item.Phone }}</view>
			<view class="phone">{{ item.CreateTime }}</view>
			<view class="address">{{ item.Province }}{{ item.City }}{{ item.Area }}{{ item.Country }}</view>
			<view class="add-pro" @click="addProduct($event,item)"><text>新增产品</text></view>
		</view>
		<view class="add-clinic" @click="addClinic">新增门店</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			inputVal: '',
			dataList: []
		};
	},
	onShow() {
		this.getData();
	},
	methods: {
		searchData(e) {
			if (e.detail.value == '') {
				this.getData();
				return;
			}
			let list = [];
			this.dataList.filter(item => {
				if (item.ShopName.includes(e.detail.value)) {
					list.push(item);
				}
			});
			this.dataList = list;
		},
		getData() {
			this.$api
				.getShopApi({
					UserId: this.common.getStore('UserId')
				})
				.then(res => {
					console.log(res, 222);
					if (res.StatusCode == 200) {
						this.dataList = res.Data;
					}
				});
		},
		addProduct(e,row) {
		
			uni.navigateTo({
				url: '/pages/addproduct/addProduct?shopId='+row.Id
			});
		},
		addClinic() {
			uni.navigateTo({
				url: '/pages/addclinic/addClinic'
			});
		}
	}
};
</script>

<style>
.index {
	padding-bottom: 100rpx;
}
.search {
	position: relative;
}
.search text {
	position: absolute;
	left: 40rpx;
	top: 50%;
	transform: translateY(-50%);
}
.search input {
	width: auto;
	border: 1px solid #ddd;
	border-radius: 50rpx;
	height: 80rpx;
	line-height: 80rpx;
	margin: 20rpx;
	padding-left: 60rpx;
}
.list {
	position: relative;
	padding: 20rpx;
	border-top: 1rpx solid #ccc;
	margin-bottom: 20rpx;
	border-bottom: 1rpx solid #ccc;
}
.list view {
	color: #555;
	font-size: 32rpx;
	line-height: 44rpx;
}
.list .title {
	color: #0196fd;
	font-size: 38rpx;
	font-weight: bold;
}
.list .add-pro {
	position: absolute;
	top: calc(50% - 30rpx);
	right: 20rpx;
}
.list .add-pro text {
	display: block;
	background: #0196fd;
	color: #fff;
	height: 60rpx;
	line-height: 60rpx;
	width: 200rpx;
	text-align: center;
	border-radius: 10rpx;
}
.add-clinic {
	height: 80rpx;
	line-height: 80rpx;
	width: 100%;
	background: #0196fd;
	color: #fff;
	text-align: center;
	position: fixed;
	bottom: 0;
	left: 0;
}
</style>
